package com.theaf.basemodule.service.impl.core;

import com.alibaba.dubbo.config.annotation.Service;
import com.theaf.basemodule.common.api.OrganService;
import com.theaf.core.api.OrganComService;
import com.theaf.core.api.model.Organ;
import com.theaf.core.api.model.OrganContact;
import com.theaf.core.utils.BeanMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Author:songwenke
 * @Description:机构外部服务
 * @Date:create in 16:29 2018/3/27
 * @Modified By:
 **/
@Service
public class OrgServiceDubboImpl implements OrganComService {

    @Autowired
    private OrganService organService;

    @Override
    public Organ findById(Long id) {
        return BeanMapper.map(organService.findById(id),Organ.class);
    }

    @Override
    public List<Organ> findCustom(String name, Long parentId, String organType) {
        return BeanMapper.mapList(organService.find(name,parentId,organType),Organ.class);
    }

    @Override
    public List<OrganContact> findOrganContact(String name, Long parentId, String organType, String contactCode) {
        return BeanMapper.mapList(organService.findContact(name,parentId,organType,contactCode),OrganContact.class);
    }

    @Override
    public List<Organ> findChild(Long id) {
        return BeanMapper.mapList(organService.findChild(id),Organ.class);
    }

    @Override
    public List<OrganContact> findChildContact(Long id, String contactCode) {
        return BeanMapper.mapList(organService.findChildContact(id,contactCode),OrganContact.class);
    }

    @Override
    public List<Organ> findAllChild(Long id) {
        return BeanMapper.mapList(organService.findAllChild(id),Organ.class);
    }

    @Override
    public List<OrganContact> findAllChildContact(Long id, String contactCode) {
        return BeanMapper.mapList(organService.findAllChildContact(id,contactCode),OrganContact.class);
    }
}
